#ifndef _CHARSTREAM_H_
#define _CHARSTREAM_H_
#include <QString>


class CharStream
{
public:
    CharStream(const QString& buf, int startline = 0, int startcolumn = 0);
    virtual ~CharStream();

    virtual QString getImage();
    virtual void done();
    virtual char readChar();

private:
    void updateLineColumn(char c);

public:
    void setTabSize(int i);
    int getTabSize();

    virtual int getEndColumn();
    virtual int getEndLine();

    virtual int getBeginColumn();
    virtual int getBeginLine();

    virtual void backup(int amount);

    virtual char beginToken();
    virtual QString getSuffix(int len);

    virtual void reInit(const QString &buf, int startline, int startcolumn);
    inline bool endOfInput() { return (_bufpos != -1 && _bufpos == _bufsize - 1) || _bufsize == 0; }
    int getCurrentPos();
    void restorePos(int pos);
    void restoreLineColPos(int endLine, int endColumn);

    virtual int getBeginPos();
    virtual int getEndPos();
private:
    int _bufpos;
    int _bufsize;
    int _tokenBegin;

    QString _buffer;
    int *_bufline;
    int *_bufcolumn;

    int _column;
    int _line;

    bool _prevCharIsCR ;
    bool _prevCharIsLF ;

    int _inBuf ;
    int _tabSize ;
};

#endif
/* JavaCC - OriginalChecksum=f9a93d1fb323f9e64b7aa5eeb59e99a6 (do not edit this line) */
